package com.ymm.system.core.jobs;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.ymm.system.api.facade.SystemCargoService;
import com.ymm.system.dao.mapper.CargoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 定时使过期货源下架
 * @auther ZhangHongyuan
 * @date 2022/8/14 22:40
 */

@Component
public class invalidCargoScheduledJob {

    @Autowired
    private SystemCargoService systemCargoService;

    @Resource
    private CargoMapper cargoMapper;

    @XxlJob("invalidCargoOutTimeOneDay")
    public ReturnT testTask(String param) throws Exception {
        List<Long> outTimeOneDayCargoIds = cargoMapper.listOutTimeOneDayCargoId();
        for (Long outTimeOneDayCargoId : outTimeOneDayCargoIds) {
            systemCargoService.cancelOnShelfCargo(outTimeOneDayCargoId, 3, 123456L);
        }
        return ReturnT.SUCCESS;
    }
}
